package yxy.game.pm2.command.daliy;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.TaskMessage;
import yxy.game.pm2.module.daily.DailyHandle;

/** 任务成就 活跃度奖励领取 */
@MessageType(proto = Command.DailyTaskVitalityBonusReceive, classtype = TaskMessage.DailyTaskVitalityBonusReceiveRequest.class)
public class CMD_DailyTaskVitalityBonusReceive extends Command<TaskMessage.DailyTaskVitalityBonusReceiveRequest> {

	@Override
	public void execute(MessageSource messageSource, TaskMessage.DailyTaskVitalityBonusReceiveRequest request) {
		String playerCode = messageSource.getTag();
		int id = request.getId();

		TaskMessage.DailyTaskVitalityBonusReceiveResponse.Builder response = TaskMessage.DailyTaskVitalityBonusReceiveResponse.newBuilder();

		Result result = new DailyHandle().levelReward(playerCode, id, response);

		send(messageSource, response, result);
	}

	private void send(MessageSource messageSource, TaskMessage.DailyTaskVitalityBonusReceiveResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}